import 'package:enterprise_v6_app/app/core/core.dart';

class CommonGasAnalysisController extends GetxController {
  /// 当前选中的标题索引
  RxInt currentIndex = 0.obs;

  /// 页面控制器
  late PageController pageController;

  @override
  void onInit() {
    super.onInit();
    pageController = PageController(initialPage: currentIndex.value);
    //监控tab切换
    pageController.addListener(() {
      //切换动画切换参数
      if (!pageController.page!.isInfinite) {
        //切换当前页面参数
        currentIndex.value = pageController.page!.round();
      }
    });
  }

  /// title选择切换
  /// [index] 页面索引
  void selectTitle(int index) {
    currentIndex.value = index;
    pageController.jumpToPage(index);
  }
}
